<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/js/kkpager.min.js"></script>
<script type="text/javascript" src="${ctx}/js/LodopFuncs.js"></script>
<object  id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
	<embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
</object>
<link rel="stylesheet" type="text/css" href="${ctx}/css/kkpager_blue.css" />
<title>员工管理</title>
</head>

<body>
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>员工管理</h2>
            </div>
            <div class="subfiled-content">
	            <div class="query_criteria">
	               <h3 style="text-indent:2em">▍查询条件</h3>
	               <div class="search-box clearfix" style="margin-top:10px;">
	                    <div class="kv-item clearfix">
	                        <label>员工名称：</label>
	                        <div class="kv-item-content">
	                            <input type="text" name="searchTxt" placeholder="员工名称" value="${searchTxt}" class="search_text" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
	                        </div>
	                    </div>
	                    <a href="javascript:;" class="sapar-btn sapar-btn-recom query-btn">查询</a>
	                </div>
	            </div>
                
                <div class="user_management">
                    <h3 style="text-indent:2em">▍用户管理列表</h3>
                       <!--表格开始-->
                <div class="table">
                    <!--表格操作-->
                    <div class="table-operate ue-clear" style="height:60px;">
                        <a href="javascript:;" class="add" style="margin-top:15px;">添加</a>
						<a href="javascript:;" class="edit" style="margin-top:15px;">修改</a>
                        <a href="javascript:;" class="del" style="margin-top:15px;">删除</a>
						<a href="javascript:dayinAll();" class="edita">打印</a>
                    </div>
                    <!--表格具体内容-->
                    <div class="table-box">
                        <table>
                            <thead>
                                <tr>
                                	<th><input type="checkbox" id="checkall" name="checkall"/></th>
                                      <th>员工条码</th>
                                      <th>员工姓名</th>
				                      <th>所属科室</th>
				                      <th>登录名称</th>
				                      <th>员工电话</th>
				                      <!-- <th>员工类型</th> -->
				                      <th>员工状态</th>
				                      <th>工作状态</th>
				                      <th>员工最新操作时间</th>
                                </tr>
                            </thead>
                            <tbody>
                            	<c:if test="${empList != null}">
		    					<c:forEach items="${empList}" varStatus="v" var="emp">
                                <tr data="${emp.employeeId }" class="empdata">
									<td><input type="checkbox" name="key" value="${emp.employeeId}"/> <input type="hidden" value="${emp.employeeNo}"/> <input type="hidden" value="${emp.employeeName}"/></td>
									  <td>${emp.employeeNo}</td>
									  <td>${emp.employeeName}</td>
				                      <td>
				                      	<c:if test="${emp.department==null}">无科室</c:if>
				                      	<c:if test="${emp.department!=null}">${emp.department.departmentName}</c:if>
				                      </td>
				                      <td>${emp.employeeLoginname}</td>
				                      <td>${emp.employeeTel}</td>
				                      <%-- <td>
				                      	<c:if test="${emp.employeeType==1 }">医生</c:if>
				    					<c:if test="${emp.employeeType==2 }">护士</c:if>
				    					<c:if test="${emp.employeeType==3 }">护士长</c:if>
				    					<c:if test="${emp.employeeType==4 }">麻醉师</c:if>
				    					<c:if test="${emp.employeeType==5 }">其他</c:if>
				                      </td> --%>
				                      <td>
				                      		<c:if test="${emp.employeeState==1 }">在职</c:if>
						    				<c:if test="${emp.employeeState==0 }">冻结</c:if>
						    				<c:if test="${emp.employeeState==-1 }">离职</c:if>
				                      </td>
				                      <td>
				                      	<c:if test="${emp.employeeWorkstate==0 }">正常</c:if>
				    					<c:if test="${emp.employeeWorkstate==1 }">借调</c:if>
				                      </td>
				                      <td><fmt:formatDate value="${emp.employeeCreatetime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                    
                                </tr>
                                </c:forEach>
                                </c:if>
                            </tbody>
                        </table>
                    </div>
                </div><!--表格结束-->
                </div>

             
            </div>
        </div>
        <div id="saper-ft">
       	 	<div id="kkpager"></div>
        </div>
    </div>
    
</body>

<script type="text/javascript">
	$(function(){
		var totalPage = ${total};
		var pageNo = getParameter('pageIndex');
		if(!pageNo){
			pageNo = 1;
		}
		//生成分页
		//有些参数是可选的，比如lang，若不传有默认值
		kkpager.generPageHtml({
			pno : pageNo,
			//总页码
			total : totalPage,
			//链接前部
			hrefFormer : '${ctx}/employee/empList',
			//链接尾部
			hrefLatter : '.do',
			getLink : function(n){
				return this.hrefFormer + this.hrefLatter + "?pageIndex="+n+"&searchTxt="+$(".search_text").val();
			}
		});
		$("#checkall").click(function(){
   		    if(this.checked){
   		        $("input[name='key']").attr('checked', true)
   		    }else{
   		        $("input[name='key']").attr('checked', false)
   		    }
	    });
		$(".query-btn").click(function(){
			window.location.href="${ctx}/employee/empList.do?searchTxt="+$(".search_text").val();
		});
		
		$(".add").click(function(){
			window.location.href="${ctx}/employee/empEdit.do";
		});
		
		$(".edit").click(function(){
			var chk_value = getSelRecord();
			if(chk_value.length == 1){
				window.location.href="${ctx}/employee/empEdit.do?id="+chk_value[0];
			}else{
				layer.msg("请选择并只能选择一条数据！");
			}
		});
		
		$(".del").click(function(){
			var chk_value = getSelRecord();
			if(chk_value.length > 0){
				layer.confirm('你确定要删除么？', function(){
					$.ajax({
			             type: "POST",
			             url:"${ctx}/employee/empDelete.do?id="+chk_value.join(),
			             error: function(request) {
			            	 	layer.alert("网络故障，请稍后再试!");
			             },
			             success: function(data) {
			 	           	if(data.status=="true"){
				 	           	layer.alert("删除成功", function(){
				 	           		window.location.reload();
			           		    });
			 	           	}else{
			 	           		layer.msg(data.msg);
			 	           	}
			             }
			         });
				});
			}else{
				layer.msg('请选择要删除的数据！');
			}
		});
		
		$("#mm").click(function(){
			window.location.href="${ctx}/employee/mimaupdate.do";              
		});
		
		$(".empdata").dblclick(function(){
			$(this).addClass("xuanzhong").siblings().removeClass("xuanzhong");
			var empid = $(this).attr("data");			//找儿子的典例
			layer.open({
				  type: 2,
				  title: '人员信息明细',
				  maxmin: true,
				  shadeClose: true, //点击遮罩关闭层
				  area : ['1000px' , '580px'],
				  content: '${ctx}/employee/empEdit.do?id='+empid
			});
		});
	});

    function dayinAll() {
        var json = dayingetSelRecord();
        console.log(json);
        for(var i=0;i<json.length;i++){
            CreatePrintPage(json[i]);
        }

    }



    //判断是否为空


    function CreatePrintPage(data) {
        var key = data.id;
        var name = data.name;
        LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
        LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_名片");
        LODOP.ADD_PRINT_RECT(10,10,256,142,0,1);
        LODOP.ADD_PRINT_TEXT(10,10,60,50,"姓名:");
        LODOP.ADD_PRINT_TEXT(10,50,170,38,name);
        LODOP.SET_PRINT_STYLE("FontSize",12);
        LODOP.SET_PRINT_STYLE("FontName","微软雅黑");
        LODOP.SET_PRINT_STYLEA(2,"FontSize",12);
        LODOP.SET_PRINT_STYLEA(3,"FontSize",12);
        LODOP.ADD_PRINT_TEXT(40,10,150,40,"条码");
        LODOP.ADD_PRINT_BARCODE(40,50,200,60,"Code39",key);
        LODOP.SET_PRINT_STYLEA(4,"FontSize",10);
        //LODOP.PREVIEW();
        LODOP.PRINT();
    };
    function dayingetSelRecord(){
        var data = [] ;
        $('input[name="key"]:checked').each(function(){
            var that = this;
            var obj = new  Object();
            var id = $(that).next().val();
            var name = $(that).next().next().val();
            obj.name = name;
            obj.id = id;
            data.push(obj);

        });
        return data;
    }

    function getSelRecord(){
        var chk_value =[];
        $('input[name="key"]:checked').each(function(){
            chk_value.push($(this).val());
        });
        return chk_value;
    }
	
	function getSelRecord(){
		var chk_value =[];
		$('input[name="key"]:checked').each(function(){
			chk_value.push($(this).val()); 
		});
		return chk_value;
	}  
	
  	function getParameter(name) { 
		var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 
		var r = window.location.search.substr(1).match(reg); 
		if (r!=null) return unescape(r[2]); return null;
	}
</script>
</html>